<?php

/**
 * This is the model class for table "{{nav}}".
 *
 * The followings are the available columns in table '{{nav}}':
 * @property integer $id
 * @property string $nav_name
 * @property string $nav_des
 * @property integer $nav_is_active
 * @property integer $nav_sort
 */
class Nav extends CActiveRecord
{
    public $id;
    public $nav_name;
    public $nav_des;
    public $nav_is_active;
    public $nav_sort;

	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	public function tableName()
	{
		return '{{nav}}';
	}

	public function rules()
	{
		return array(
			array('nav_name', 'required'),
            array('nav_name', 'unique'),
			array('nav_is_active, nav_sort', 'numerical', 'integerOnly'=>true),
			array('nav_name', 'length', 'max'=>10, 'min'=>3),
			array('nav_des', 'length', 'max'=>255),
			array('nav_sort', 'length', 'max'=>4),
			array('id, nav_name, nav_des, nav_is_active, nav_sort', 'safe', 'on'=>'search'),
		);
	}

	public function relations()
	{
		return array(
		);
	}

	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'nav_name' => '导航名称',
			'nav_des' => '导航描述',
			'nav_is_active' => '是否激活',
			'nav_sort' => '导航排序',
		);
	}

	public function search()
	{
		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('nav_name',$this->nav_name,true);
		$criteria->compare('nav_des',$this->nav_des,true);
		$criteria->compare('nav_is_active',$this->nav_is_active);
		$criteria->compare('nav_sort',$this->nav_sort);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}